package com.opo5.logisticsmanagement.controller;




import com.baomidou.mybatisplus.core.metadata.IPage;
import com.opo5.logisticsmanagement.common.R;
import com.opo5.logisticsmanagement.domain.VehicleInsurance;
import com.opo5.logisticsmanagement.domain.VehicleList;
import com.opo5.logisticsmanagement.service.VehicleInsuranceService;
import com.opo5.logisticsmanagement.service.VehicleListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
@Slf4j
@RestController
@ResponseBody
@RequestMapping("tbsV")
@CrossOrigin
public class TbsVehicleInsuranceController {
    @Autowired(required = false)
    private VehicleInsuranceService vehicleInsuranceService;

    /**
     *
     * @param currentPage
     * @param pageSize
     * @param vehicleInsurance
     * @return
     */
    @GetMapping("/{currentPage}/{pageSize}")
    public R getAllIN(@PathVariable int currentPage,@PathVariable int pageSize,VehicleInsurance vehicleInsurance){
        IPage<VehicleInsurance>page=vehicleInsuranceService.selectPage(currentPage,pageSize,vehicleInsurance);
        return R.success(page);
    }

    /**
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R delList(@PathVariable int id){
        vehicleInsuranceService.removeById(id);
        return R.success("删除成功");
    }
    @PostMapping
    public R addList(@RequestBody VehicleInsurance vehicleInsurance){
        vehicleInsuranceService.save(vehicleInsurance);
        return  R.success("增加成功");
    }
    @PutMapping
    public R updateList(@RequestBody VehicleInsurance vehicleInsurance){
        vehicleInsuranceService.updateById(vehicleInsurance);
        return R.success("修改成功");
    }
}
